Page({
  onLoad({ id }) {
    this.getPassport(id)
  },
  //获取通行证数据
  async getPassport(id) {
    const detail = await wx.http.get(`/visitor/${id}`)
    // encryptedData: "bbc4870ea0512816186904bb378220f7551b262cffecfba077a71268037784e7"
    // houseInfo: "裕祥小区(中山口路)5号楼474"
    // id: "6966162727649280"
    // url: "https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/livimini/visitUrl.png"
    // validTime: 30866
    console.log(detail);
    //结构出来 直接可以使用   不用在单独赋值 存变量
    this.setData({
      ...detail
    })
  },
  //保存图片到相册
  async saveImg() {
    //把网络图片转换成本地图片
    const res = await wx.getImageInfo({ src: this.data.url })
    console.log("本地图片", res.path);
    //保存图片到相册
    await wx.saveImageToPhotosAlbum({ filePath: res.path })
    wx.utils.message('保存成功')
  },
  onShareAppMessage() {
    return {
      title: '查看通行证',
      path: '/visitor_pkg/pages/passport/index',
      imageUrl: 'https://enjoy-plus.oss-cn-beijing.aliyuncs.com/images/share_poster.png',
    }
  },
})
